#{extends 'main.html' /}
#{set title:'Showing project: '+project.name /}
#{set 'crumbs'}
<li><a href="/show/projects">Projects</a></li>
<li><a href="/show/project?id=${project.id}">${project.name}</a></li>
#{/set}
<h2>${project.name}</h2>
<div class="notchTop"></div>
<div class="allCornersRounded projDes">
${project.description?.nl2br()}
</div><div>
<ul class="project_links">
<a  href="@{Projects.getProjectMembers(project.id)}"><img src="@{'/public/images/users.png'}"/>Members(${memberscount})</a>

<a  href="tasks?id=${project.id}"><img src="@{'/public/images/TASKS.png'}"/>Tasks(${taskscount})</a>
<!-- adding component's link by Amr Hany -->
<a  href="/projects/${project.id}/components"><img src="@{'/public/images/SOFTWARE.png'}"/>Components(${componentscount})</a>

<!-- adding sprints' link by minazaki -->
<a  href="@{Sprints.showsprints(project.id)}" ><img src="@{'/public/images/sprint.png'}"/>Sprints(${sprintscount})</a>

<!-- adding meetings link @author ghadafakhry -->
<a  href="/projects/${project.id}/meetings"><img src="@{'/public/images/cal.png'}"/>Meetings(${meetingscount})</a>

<!-- adding meetings link @author ahmedKhaled7 -->
<a  href="/productbacklog/${project.id}/0"><img src="@{'/public/images/FILE - EXECUTABLE.png'}"/>Product Backlog</a>

<!--  adding impediment tasks @author Hadeer Younis -->
<a  href="@{ImpedimentTasks.viewImpedimentLog(project.id)}"><img src="@{'/public/images/log.png'}"/>Impediment Log</a>

<!-- adding product role's link by Heba Elsherif -->
<a  href="/projects/${project.id}/productroles"><img src="@{'/public/images/role.png'}"/>Product Roles</a>


<!--  Stories : Galal Aly -->
<a  href="@{Storys.listStoriesInProject(project.id)}"><img src="@{'/public/images/BOOK.png'}"/>Stories(${storiescount})</a>
<!--  End Of Stories --><div class="left">
<a href="javascript:;" onclick="$('#boards').css('display','none');$('#roles').slideToggle(400)"><img src="@{'/public/images/addrole.png'}"/>Request Roles</a>
<br style="clear:both"/>
<div id="roles" style="margin-left:-100px;margin-right:-50px;position:relative;width:300px;z-index:999;display:none"><div class="notchTop" style="margin:0px auto"></div>
<div class="allCornersRounded proj" style="width:280px;padding:10px;overflow:auto">
	#{list items:project.roles, as:'role'}
		#{if !connected.roles.contains(role)}
		#{set requested: requestedRoles.contains(role) /}
		<div style="float:left;width:200px;">${role.name}</div>
		<div style="float:left;">
		<form style="display:inline;" action="/projecttasks/requestrole?id=${role.id}" method="post">
			<input type="submit" value="request${requested ? 'ed' : ''}" class="${requested ? 'disabled' : ''}" ${requested ? 'disabled':''} /></form>
		</div>	

		#{/if}
	#{/list}</div></div></div>
	<div class="left">
<!-- view boards @ author Dina Helal -->
<a  href="javascript:;" onclick="$('#roles').css('display','none');$('#boards').slideToggle(400)"><img src="@{'/public/images/DESKTOP.png'}"/>Boards</a>
<br style="clear:both"/>


<div id="boards" style="display:none;margin-left:-50px;margin-right:-50px;position:relative;width:210px;z-index:999;"><div class="notchTop" style="margin:0px auto"></div>
<div  class="allCornersRounded proj" style="width:200px;float:left;padding:10px">
	#{list items:project.sprints, as:'sprint'}
		<a href="javascript:;" onclick="$('#s_${sprint.id}').toggle()"  style="float:left;width:200px;">Sprint ${sprint.sprintNumber}</a><br/>
		<div id="s_${sprint.id}" style="display:none; margin-left:10px">
		
#{if sprint.ended==true}



#{/if}

#{if sprint.ended!=true }
<a href="javascript:" onclick="$('#c_${sprint.id}').toggle()" title="view components' boards?" style="margin-left:20px;float:left;width:200px;">View Components' Boards</a>
	#{/if}
		<div id="c_${sprint.id}" style="display:none; margin-left:40px">
		#{list items:sprint.project.components, as:'component'}


#{if sprint.ended!=true }
<a id="component${component.id} style="margin-left:20px" title="${component.name}'s sprint ${sprint.id} Task Board?"href="/boards/loadBoard1?sprintID=${sprint.id}&componentID=${component.id}">${component.name}</a>
		
	#{/if}
		#{/list}
		</div>
		</div>
		#{/list}
		</ul>
</div></div></div></div>
#{set 'moreLinks'}
#{if connected.in(project).can('editProject')}
<p><a href="/admin/projects/${project.id}">Edit Project Settings</a></p>
#{/if}
<p>
	<a href="@{ProductBacklogs.showGraph(project.id,0)}">View Burn down Charts</a>
</p>

<!--@author ahmedkhaled7 C4S12/c4S4/c4s5   -->
<p>
	<a href="@{ImpedimentTasks.index(project.id)}">Report impediment</a>
</p>
#{if connected.in(project).can('canManageRoles')}<p>
	<a href="/show/roles?id=${project.id}">Manage roles (${project.roles.size()})</a>
</p>#{/if}

<p>
	<a href="@{Storys.listStoriesandSprints(project.id)}">Assign story to sprint </a>
</p>
<!-- adding a check requests link @author moataz_mekki -->
#{if connected.in(project).can('canManageRequests')}
<p>
	<a href="/projects/requestrespond?id=${project.id}">Check requests (${project.getNumberOfTotalRequests()})</a>
</p>
#{/if}

<!-- project notification profile @ author moataz_mekki-->
#{if connected.in(project).can('canEditProjectNotificationProfile')}
<p>
	<a href = "/projects/managenotificationprofile?projectId=${project.id}">Edit project (whole) notifications </a>
</p>
#{/if}
#{if connected.in(project).can('respond')}
<p>
	<a href="/Requestreviewers/respond?id=${project.id}">Respond to reviewer requests</a>
</p>
#{/if}
#{/set}

#{set 'moreControls'}
<!-- adding a manage notifications link for each user to manage his notification 
profile related to this project
@author Amr Tj.Wallas 
@Task C1S33 -->
#{if connected.in(project).can('canEditUserNotificationProfile')}
<p>
	<a href = "/users/managenotificationprofile?id=${project.id}">Manage my notifications</a>
</p>
#{/if}
#{if project.users.contains(connected)}<p>
	<a href="/Projects/requestdeleted?id=${project.id}" onclick="return confirm('Are you sure you want to be deleted from this project??? \n YOU WONT BE ABLE TO CONTRIBUTE IN THIS PROJECT ANYMORE \n HOWEVER YOUR WORK WILL STILL BE VISIBLE BY ALL PROJECT MEMBERS')"> Request Deletion</a>
</p>
#{/if}


#{if connected.in(project).can('deleteProject')}
#{if project.hasRunningSprints()}

<a href = "#"  name="deleteProject" onclick="delete_project(${project.id})"  >Delete Project</a>
#{/if}
#{else}
<a href = "#"  name="deleteProject" onclick="delete_project_ns(${project.id})"  >Delete Project</a>
#{/else}
#{/if}

#{/set}
</div>



<script type="text/javascript">
function delete_project(id)
{
   alert("There is Running Sprint..Project cannot be deleted");
}

function delete_project_ns(id)
{
	var confirmation= confirm("Are you sure you want to delete this Project ?");
	
	if (confirmation) {
		$.post('@{deleteProject()}', {
			id:id
		}, function(){
			window.location = "/show/projects"
		});
	}
	else
		window.location = "/show/projects"
	return true
	;		
}



</script>
<script type="text/javascript">
function isAfter(date){
	var now=new Date();
	var other=new Date(date);
	if(now>other){
	return  true;
		}
	else{
	return false;
		}
}</script>
